/*
 * @Description: 
 * @Author: dengzhijun
 * @Date: 2025-01-17 11:48:49
 * @LastEditTime: 2025-01-24 10:27:17
 * @LastEditors: dengzhijun 1726768643@qq.com
 */
#ifndef TOOLS_LOGGERS_H
#define TOOLS_LOGGERS_H

#include <iostream>
#include <string>
#include <thread>
#include <atomic>
#include <fstream>
#include <memory>
#include <filesystem>
#include <cstdarg>
#include "include/ILogger.h"

namespace Tool
{

struct FileInfo;
class ExportAPI Loggers : public ILogger
{
public:
    Loggers();
    virtual ~Loggers();
    virtual void Write(const char *fileName, int lineNumber, LogLevel level,std::string logerName, const char *format, ...) override;
    virtual void SetOutputToConsole(bool output) override;
    virtual void SetLevel(LogLevel level) override;
private:
    Loggers(const Loggers &) = delete;
    Loggers &operator=(const Loggers &) = delete;
    bool Init();
    void UnInit();
    void AsyncWriteLog();
    void WriteToLogFile(const std::string& loggerName, const std::string& logMsg);
    void WriteToTotalLogFile(const std::string& logMsg);
    void RotateTotalLogFile();
    inline std::string GetLogFileName(const std::string &logerName);
    inline void WriteToSingleFile(const std::string& logerName, FileInfo& fileInfo, const char *content, int contentLen);
private:
    struct LoggersPrivater;
    LoggersPrivater *m_privater = nullptr;
};

}
#endif // LOGGER_H
